package groupb6.shopsystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import groupb6.shopsystem.pojo.entity.Order;
import groupb6.shopsystem.pojo.entity.Product;
import groupb6.shopsystem.pojo.entity.ShoppingBag;
import groupb6.shopsystem.pojo.entity.User;
import groupb6.shopsystem.util.response.UniversalResponse;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrderMapper extends BaseMapper<Order> {

    @Select(" SELECT * FROM tb_order WHERE seller_id = #{sellerId};")
    List<Order> getOrdersBySellerId(Integer sellerId);
    @Select("select * from tb_order where buyer_id=#{buyer_id}")
    List<Order> getOrderByBuyerId(Integer buyer_id);

    @Select("select * from tb_order where id=#{id}")
    Order getOrderByorderId(Integer id);

    @Select("select * from tb_product where id=#{id} and stock<#{number}")
    List<Product> check(Integer id,Integer number);

    @Select("select * from tb_order where status = 3")
    List<Order> listShippedOrders();

    @Update("update tb_order set status = 4 where status = 3")
    void deliveredShippedOrders();

}
